<?php
namespace app\modules\api\controllers;
use yii\web\Controller;
use Yii;
/**
 * Default controller for the `api` module
 */
class DefaultController extends Controller
{
    /**
     * Renders the index view for the module
     * @return string
     */
    //此代码的作用是关闭csrf验证(默认post请求方式会开启csrf验证)
    public function init(){
        $this->enableCsrfValidation = false;
    }
    public function actionHandel()
    {
        //如果是post请求的时候
        if(Yii::$app->request->isPost){
            $request = Yii::$app->request;
            $post = $request->post();
            var_dump($post);
            exit();
        }
        //如果不是post请求的时候
        $response = Yii::$app->response;
        $response->format = \yii\web\Response::FORMAT_JSON;
        return ['code'=>200, 'msg'=>"接口请求成功"];
    }
    public function actionCreate(){
        var_dump(555);
       $parameter= Yii::$app->request->Post();
       var_dump($parameter);
       exit();
    }
}
